<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>

<div id="test">
  <div id="normal-div"></div>
  <div id="shadow-host-v0"></div>
  <div id="shadow-host-v1"></div>
</div>

<script>
const normalDiv = document.querySelector('#normal-div');
const shadowHostV1 = document.querySelector('#shadow-host-v1');
shadowHostV1.attachShadow({mode : 'open'});
const test_event = new Event('test_event');

async_test((test) => {
  normalDiv.addEventListener('test_event', test.step_func_done((e) => {
    assert_not_equals(event, null);
    assert_equals(event, e);
    assert_equals(event, test_event);
  }));
  normalDiv.dispatchEvent(test_event);
}, 'window.event should contain the current event being handled when the target is a normal DOM node');

async_test((test) => {
  shadowHostV1.shadowRoot.addEventListener('test_event', test.step_func_done((e) => {
    assert_equals(event, undefined);
    assert_not_equals(event, e);
  }));
  shadowHostV1.shadowRoot.dispatchEvent(test_event);
}, 'window.event should be undefined when the target of the current event being handled is a V1 Shadow DOM node');

</script>
